package com.human.server.config;

import cn.dev33.satoken.exception.NotLoginException;
import com.human.server.model.MessageType;
import com.human.server.model.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class CustomControllerAdvice {

    @ExceptionHandler(Exception.class)
    public R exceptionHandler(Exception e) {

        log.error("异常信息：", e);
        return R.fail("系统异常");
    }

    @ExceptionHandler(NotLoginException.class)
    public R exceptionHandler(NotLoginException e) {
        log.error("参数校验异常：", e);
        return R.fail(MessageType.NOT_LOGIN);
    }
}
